<?php
session_start();

include 'default_includes.php';

if(isset($_POST["login"]) && $_POST["login"] != "") {
	$requete_connexion = "SELECT * FROM piltrade_user WHERE LOGIN = '".$_POST["login"]."' AND PASS = '".md5($_POST["pass"])."' ";
	$query = $db->executeQuery($requete_connexion);
	if(mysql_num_rows($query) == 1) {
		$_SESSION["connected"] = 1;
		//Redirection sur la page logged
		header(sprintf("Location: %s", "index_logged.php"));
	}
}
?>
<html>
	<head>
		<title>PilTrade</title>
		<link rel="stylesheet" type="text/css" href="css/style.css" />
		<script language="javascript">
			function onLoadActions() {
				document.getElementById("login").focus();
				document.getElementById("login").select();
			}
		</script>
	</head>
	<body onload="onLoadActions();">
		<form action="index.php" method="post">
			<div class="center" align="center">
				<h1 class="center">Connexion</h1>
				<table class="tableau center" align="center" width="80%">
					<tr>
						<td>Login</td>
						<td><input type="text" name="login" value="" id="login" /> </td>
					</tr>
					<tr>
						<td>Pass</td>
						<td><input type="password" name="pass" value="" /></td>
					</tr>
				</table>
				<input type="submit" /> 
			</div>
		</form>
	</body>
</html>
<?php $db->disconnect(); ?>